home *** CD-ROM | disk | FTP | other *** search
- // return the param passed in from the URL after the ? (i.e. - "http://buildframes.html?respiratory/conresp")
- // would return "respiratory/conresp"
- function getParamFromURL() {
- vsURL = new String(document.location);
-
- vsParam = vsURL.substring(vsURL.indexOf("?") + 1, vsURL.length);
-
- return vsParam;
- }
-
- // return the number of items in a string delimited by xsDelimiter
- // returns 1 if no delimiters so "" returns 1 whereas "," returns 2
- function getNumberOfItemsFromDelimitedString(xsStringToSplit, xsDelimiter) {
- vsSplitArray = xsStringToSplit.split(xsDelimiter);
-
- return vsSplitArray.length;
- }
-
- // return the nth item from a string delimited by xsDelimiter
- function getNthItemFromDelimitedString(xsStringToSplit, xiWhich, xsDelimiter) {
- vsSplitArray = xsStringToSplit.split(xsDelimiter);
-
- return vsSplitArray[xiWhich - 1];
- }
-
- // return the nth item from a string delimited by xsDelimiter
- function getLastItemFromDelimitedString(xsString, xsDelimiter) {
- vsSplitArray = xsString.split(xsDelimiter);
- vsItemToReturn = getNthItemFromDelimitedString(xsString, vsSplitArray.length, xsDelimiter);
-
- return vsItemToReturn;
- }
-
- // strip the nth item from a string delimited by xsDelimiter (and the last delimiter)
- function stripLastItemFromDelimitedString(xsStringToStrip, xsDelimiter) {
- // get the location of the last comma (the char before the param)
- viLastDelimLoc = xsStringToStrip.lastIndexOf(xsDelimiter);
-
- if(viLastDelimLoc != -1)
- vsToReturn = xsStringToStrip.substring(0, viLastDelimLoc);
- else
- vsToReturn = xsStringToStrip;
-
- return vsToReturn;
- }
-
-
- // pad a number (as a string) with leading 0's
- function padNumToXDigits(xsNumAsString, xiNumDigits) {
- vsCurrentStringLen = xsNumAsString.length;
- for(i=vsCurrentStringLen; i<xiNumDigits; i++) {
- xsNumAsString = "0" + xsNumAsString;
- }
-
- return xsNumAsString;
- }
-
- // change the image xsImageName to the xsImageSrc
- function swapImages(xsImageName, xsImageSrc) {
- if (document.images) {
- document.images[xsImageName].src = xsImageSrc;
- }
- }
-